package com.sunnay.controller;

import com.sunnay.service.DepositInfoService;
import com.sunnay.util.R;
import com.sunnay.vo.product.BidRequestVo;
import com.sunnay.vo.product.CancelDepositVo;
import com.sunnay.vo.product.DepositVo;
import com.sunnay.web.ContextHelper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private DepositInfoService depositInfoService;

    //提交托管
    @PostMapping("/deposit")
    public R<Boolean> publishDeposit(@RequestBody DepositVo depositVo){
        depositInfoService.publishDeposit(depositVo, ContextHelper.getSystemUser());
        return R.ok();
    }

    @PutMapping("/cancel")
    public R<Boolean> cancelDeposit(@RequestBody CancelDepositVo depositVo){
        depositInfoService.cancelDeposit(depositVo);
        return R.ok();
    }

    @PostMapping("/bid")
    public R<Boolean> publishBid(@RequestBody BidRequestVo requestVo){
        depositInfoService.publishBid(requestVo, ContextHelper.getSystemUser());
        return R.ok();
    }
}
